package com.leonzx.base.controller.information;

import com.leonzx.base.controller.base.BaseController;
import com.leonzx.base.entity.system.Information;
import com.leonzx.base.entity.system.Role;
import com.leonzx.base.entity.system.User;
import com.leonzx.base.service.system.InformationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author:李晓雷
 * @Description:
 * @Date: 18/07/11 13:58
 */
@Controller
@RequestMapping("/information")
public class InformationController extends BaseController {
    @Autowired
    private InformationService informationService;
    /**
     * 静态模版所在路径前缀
     */
    private String prefix = "information";
    /**
     * 短信页面
     * @return
     */
    @RequestMapping("/list")
    public String list (){
        return prefix + "/list";
    }
    /**
     * 跳转到用户添加页面
     *
     * @return
     */
    @RequestMapping("/add")
    @RequiresPermissions("/information/list")
    public String add(Information information, Model model) {
        model.addAttribute("information", information);
        return prefix + "/edit";
    }
    /**
     * 根据前台传值id查询编辑短信，返回编辑页面
     *
     * @param information
     * @param model
     * @return
     */
    @RequestMapping("/edit")
    @RequiresPermissions("/role/torolelist")
    public String toedit(Information information, Model model) {
        Information information1 = informationService.findById(information);
        model.addAttribute("information", information1);
        return prefix + "/edit";
    }
}
